//package sc.test.spring.quartz;
//
//import java.util.Date;
//
//import org.quartz.DisallowConcurrentExecution;
//import org.quartz.Job;
//import org.quartz.JobDataMap;
//import org.quartz.JobDetail;
//import org.quartz.JobExecutionContext;
//import org.quartz.JobExecutionException;
//import org.quartz.JobKey;
//import org.quartz.PersistJobDataAfterExecution;
//import org.quartz.Trigger;
//
//import sc.common.test.DateUtil;
//import sc.common.test.TestUtil;
//
//@PersistJobDataAfterExecution
//@DisallowConcurrentExecution
//public class CoolJob implements Job {
//
//    public static final String EXE_COUNT = "EXE_COUNT";
//    public static final String DELAY_SECONDS = "DELAY_SECONDS";
//
//    public Integer executeCount;
//    public Integer delaySeconds;
//
//    public void doInit(JobDataMap jobDataMap, JobDataMap triggerDataMap) {
//        if (jobDataMap.containsKey(EXE_COUNT)) {
//            executeCount = jobDataMap.getInt(EXE_COUNT);
//        } else {
//            executeCount = 0;
//        }
//        if (triggerDataMap.containsKey(DELAY_SECONDS)) {
//            delaySeconds = triggerDataMap.getInt(DELAY_SECONDS);
//        } else {
//            delaySeconds = 0;
//        }
//    }
//
//    public void dofinal(JobDataMap jobDataMap, JobDataMap triggerDataMap) {
//        jobDataMap.put(EXE_COUNT, executeCount);
//        jobDataMap.put(DELAY_SECONDS, delaySeconds);
//    }
//
//    @Override
//    public void execute(JobExecutionContext paramJobExecutionContext) throws JobExecutionException {
//        JobDetail jobDetail = paramJobExecutionContext.getJobDetail();
//        Trigger trigger = paramJobExecutionContext.getTrigger();
//        Date schedFireTime = paramJobExecutionContext.getScheduledFireTime();
//        JobKey jobKey = jobDetail.getKey();
//        doInit(jobDetail.getJobDataMap(), trigger.getJobDataMap());
//        try {
//            executeCount++;
//            String logPrefix = String.format("(%d)JobKey = %s", executeCount, jobKey);
//            TestUtil.sp("%s schedFireTime[%s], start", logPrefix, DateUtil.format(schedFireTime));
//            TestUtil.sp("%s, sleep %d(s)", logPrefix, delaySeconds);
//            TestUtil.keepAlive(delaySeconds);
//            TestUtil.sp(logPrefix + ", end");
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        } finally {
//            dofinal(jobDetail.getJobDataMap(), trigger.getJobDataMap());
//        }
//    }
//}
